package module16;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.openqa.selenium.support.events.internal.EventFiringMouse;


public class Mouse_EventFiringMouse {

	/**
	 * @param args
	 */
	public static WebDriver Web_driver ;
	public static void main(String[] args) {
		Web_driver = new FirefoxDriver();
EventFiringWebDriver driver = new EventFiringWebDriver(Web_driver);
MyListener listener = new MyListener();

driver.register(listener);

driver.get("http://timesofindia.indiatimes.com");
EventFiringMouse mouse = new EventFiringMouse(driver, listener);

Locatable locate = (Locatable) driver.findElement(By.xpath("//*[@id='citydiv']/span/ul/li[2]/a"));
Coordinates cordinate = locate.getCoordinates();
try
{
	mouse.mouseMove(cordinate);
	mouse.click(cordinate);
	
}
catch(Throwable t)
{
	System.out.println("Error");
}

//right click with the mouse
driver.findElement(By.xpath("//*[@id='citydiv']/span/ul/li[2]/a")).sendKeys(Keys.chord(Keys.SHIFT, Keys.F10));

//get the coordinates of particular links
Point p = driver.findElement(By.xpath("//*[@id='citydiv']/span/ul/li[2]/a")).getLocation();
System.out.println("X:" +p.x);
System.out.println("X:" +p.y);

	}

}
